<template>
	<view>
		<evaluates :evaList="evaList" :isempty="isempty" :isloading="isloading" :isDel="true" @del="del"></evaluates>
	</view>
</template>

<script>
	import evaluates from '../../components/evaluates.vue'
	export default {
		data() {
			return {
				evaList:[],
				page: 0,
				isempty: false,
				isloading: false,
				uid: ''
			};
		},
		components: {
			evaluates
		},
		onLoad(option){
			this.uid = option.uid;
			this.getList()
		},
		onReachBottom(){
			this.getList()
		},
		methods: {
			getList(){
				this.isloading = true;
				this.isempty = false;
				this.page++;
				this.$axios('Index/getShopComment', 'POST', 'supplier', {
					uid: this.uid,
					page: this.page
				}).then(res => {
					this.isloading = false;
					if (res.data.code == 200) {
						this.evaList = [...this.evaList, ...res.data.data.list];
						this.isempty = res.data.data.list.length <= 0;
					}
				})
			},
			del(id){
				// if(id){
					var that = this;
					uni.showModal({
						title: '提示',
						content: '确定要删除这条评价吗？',
						success: function (res) {
							if (res.confirm) {
								console.log('用户点击确定');
								that.$axios('index/delShopComment','POST','supplier',{
									id: id
								}).then(res=>{
									if(res.data.code==200){
										that.page=0;
										that.evaList = [];
										that.getList();
										that.$api.msg('删除成功');
									}
								})
							} else if (res.cancel) {
								console.log('用户点击取消');
							}
						}
					});
				// }
			}
		}
	}
</script>

<style lang="scss">

</style>
